package com.lemon.soft.bookingroom.controller;

import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.Map;


import com.lemon.soft.bookingroom.dto.CancellationDTO;
import com.lemon.soft.bookingroom.util.PageUtils;
import com.lemon.soft.bookingroom.util.R;
import com.lemon.soft.bookingroom.vo.CancelVo1;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.lemon.soft.bookingroom.entity.CancellationRecordsEntity;
import com.lemon.soft.bookingroom.service.CancellationRecordsService;



/**
 * 
 *
 * @author ${author}
 * @email ${email}
 * @date 2025-05-29 12:38:52
 */
@CrossOrigin
@Tag(name = "取消预订记录")
@RestController
@RequestMapping("bookingroom/cancellationrecords")
public class CancellationRecordsController {
    @Autowired
    private CancellationRecordsService cancellationRecordsService;

    /**
     * 申请取消预订
     */
    @Operation(summary = "客户申请取消")
    @PostMapping("/apply/{userId}")
    public R applyCancellation(@RequestBody CancellationDTO cancellationDTO,
                               @PathVariable("userId") Integer userId) {
        cancellationDTO.setCancelTime(LocalDateTime.now()); // 设置当前时间为取消时间
        String success = cancellationRecordsService.applyCancellation(cancellationDTO, userId);
        return R.ok().put("data", success);
    }

    /**
     * 审核取消预订
     */
    @Operation(summary = "工作人员审核")
    @PostMapping("/review")
    public R reviewCancellation(@RequestBody CancelVo1 cancelVo1) {
        Integer cancellationId=cancelVo1.getCancellationId();
        Integer staffId=cancelVo1.getStaffId();
        Integer reviewStatus=cancelVo1.getReviewStatus();
        String reviewRemark=cancelVo1.getReviewRemark();
        String success = cancellationRecordsService.reviewCancellation(
                cancellationId, staffId, reviewStatus, reviewRemark);
        return R.ok().put("data", success);
    }
    /**
     * 列表
     */
    @Operation(summary = "获取取消预订记录列表")
    @GetMapping("/list")
    public R list(){
        R r= cancellationRecordsService.queryPage();

        return r;
    }

    @Operation(summary = "驳回")
    @PostMapping("/reject/{cancellationId}")
    public R reject(@PathVariable("cancellationId") Integer cancellationId) {
        cancellationRecordsService.removeById(cancellationId);
        return R.ok();
    }






}
